//
//  AdvisoryViewCell.swift
//  EyeVisionForPatients
//
//  Created by PMC on 2020/2/7.
//  Copyright © 2020 tao Tao. All rights reserved.
//

import UIKit

class AdvisoryViewCell: UITableViewCell {
    
    static let reuseIdentifier = "advisoryCellID"

    func configure(with vm: AdvisoryViewModel.RowViewModel) {
        avatarView.kf.setImage(with: URL(string: vm.avatar),
                               placeholder: UIImage(named: "avatar_default"))
        nameLabel.text = vm.doctor
        descLabel.text = vm.lastMsg
        timeLabel.text = vm.lastMsgTime
        tipBadge.text = vm.unreadCount
        tipBadge.isHidden = vm.isHiddenUnread
        departmentLabel.text = vm.department
        if vm.businessType == 1 {
            businessTypeLabel.text = "咨询"
        }else if vm.businessType == 2{
            businessTypeLabel.text = "复诊"
        }
    }
    
    @IBOutlet weak var avatarView: UIImageView! {
        didSet {
            avatarView.contentMode = .scaleAspectFill
            avatarView.layer.cornerRadius = avatarView.height * 0.5
            avatarView.layer.masksToBounds = true
        }
    }
    
    @IBOutlet weak var businessTypeLabel: UILabel!{
        didSet{
            businessTypeLabel.layer.cornerRadius = 5
            businessTypeLabel.layer.masksToBounds = true
        }
    }
    @IBOutlet weak var nameLabel: UILabel!
    @IBOutlet weak var descLabel: UILabel!
    @IBOutlet weak var timeLabel: UILabel!
    @IBOutlet weak var tipBadge: UILabel! {
        didSet {
            tipBadge.layer.cornerRadius = tipBadge.height * 0.5
            tipBadge.layer.masksToBounds = true
        }
    }
    
    @IBOutlet weak var departmentLabel: UILabel! {
        didSet {
            departmentLabel.textColor = .mainColor
        }
    }
}
